﻿//-----------------------------------------------------------------------
// <copyright file="SampleData.cs" company="CMSN Software">
//    Copyright © 2011  CMSN Software
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see http://www.gnu.org/licenses.
// </copyright>
//-----------------------------------------------------------------------
namespace CMSN.Software.Tutorials.HowToUseCustomPagination
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Globalization;
    using System.Linq;
    using System.Web;

    /// <summary>
    /// sample data for custom pagination
    /// </summary>
    public sealed class SampleData
    {
        /// <summary>
        /// Prevents a default instance of the <see cref="SampleData"/> class from being created.
        /// </summary>
        private SampleData()
        {
        }

        /// <summary>
        /// Sample data list with pagination.
        /// </summary>
        /// <param name="startIndex">The start index.</param>
        /// <param name="pageSize">Size of the page.</param>
        /// <returns>Sample data list</returns>
        public static Dictionary<string, string> SampleDataList(int startIndex, int pageSize)
        {
            Dictionary<string, string> sampleTable = new Dictionary<string, string>();
            var query = from p in TemporaryData()
                        .Take(pageSize)
                        .Skip(startIndex)
                        select new
                        {
                            FirstColumn = p.Key,
                            SecondColumn = p.Value
                        };
            foreach (var row in query)
            {
                sampleTable.Add(row.FirstColumn, row.SecondColumn);
            }

            return sampleTable;
        }

        /// <summary>
        /// Temporary data.
        /// </summary>
        /// <returns>Temporary data</returns>
        public static Dictionary<string, string> TemporaryData()
        {
            Dictionary<string, string> sampleDataSet = new Dictionary<string, string>();
            for (int i = 1; i <= 49; i++)
            {
                sampleDataSet.Add("Raw " + i + " Cell 1", "Raw " + i + " Cell 2");
            }

            return sampleDataSet;
        }
    }
}